<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Admin extends MY_Controller
{
    /** @var \User */
    private $CurrentUser;

    public function __construct()
    {
        parent::__construct();

        // 检查状态
        YimeDevTools::checkSiteStatus();

        $SiteName          = Option_Model::getOption('site_name');
        $this->CurrentUser = UserManager::getCurrentUserBySession();

        // 权限过滤
        if ($this->CurrentUser->getPower() < 99999) {
            show_404();
        }

        $this->load->vars(array(
            'SiteName'    => $SiteName,
            'CurrentUser' => $this->CurrentUser,
        ));
    }

    public function index()
    {
        $this->load->view('admin/html-header');
        $this->load->view('admin/header');
        $this->load->view('admin/homepage');
        $this->load->view('admin/footer');
        $this->load->view('admin/html-footer');
    }

    public function listUser()
    {
        $this->load->vars(array('UserArray' => User_Model::getUserArray()));

        $this->load->view('admin/html-header');
        $this->load->view('admin/header');
        $this->load->view('admin/list-user');
        $this->load->view('admin/footer');
        $this->load->view('admin/html-footer');
    }

    public function listSchool()
    {
        $this->load->vars(array('SchoolArray' => School_Model::getSchoolArray()));

        $this->load->view('admin/html-header');
        $this->load->view('admin/header');
        $this->load->view('admin/list-school');
        $this->load->view('admin/footer');
        $this->load->view('admin/html-footer');
    }

    public function listCommodity()
    {
        $this->load->vars(array('CommodityArray' => Commodity_Model::getCommodityArray()));

        $this->load->view('admin/html-header');
        $this->load->view('admin/header');
        $this->load->view('admin/list-commodity');
        $this->load->view('admin/footer');
        $this->load->view('admin/html-footer');
    }
}